package type.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @Date 2021/5/2 10:56 上午
 * @Author dengxin
 */
public class MethodDynamicProxyHandler implements InvocationHandler {

    private SomeMethod proxied;

    public MethodDynamicProxyHandler(SomeMethod proxied) {
        this.proxied = proxied;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        if (method.getName().contains("interesting")) {
            System.out.println("This is the Interesting Method");
            return method.invoke(proxied, args);
        }
//        return method.invoke(proxied, args);
        return null;
    }
}
